var icPatronChat=icPatronChat||function(){var initialH=0;var initialW=0;var chatButtonH=80;var chatButtonW=180;var minH=0;var minW=0;var chatH=600;var chatW=380;var _frame=null;var _chatButtonFrame=null;var _host=null;var isIpad=false;var popOutChat;var CHILD_WINDOW_HANDLE=null;var _url="";var win;var showBadge;var customChatButton=false;var xMax;var yMax;var minHeight=400;var minWidth=380;var customWidth=null;var customHeight=null;var windowConfig=null;var browserScrollWidth=21;var windowScrollWidth=17;var leftPos;var topPos;var sessionParameter=[];function resizeChat(frame,h,w){if(frame){frame.height=h;frame.width=w}}function addCss(position){var css=".ie-div-position-customer-chat {display: block;} .chat-iframe-wrap {border-radius: 5px 5px 0 0;z-index: 2147483000;position: fixed;bottom: 100px;width: 380px;min-height: 300px;border-radius: 8px;overflow: hidden;opacity: 1;height: calc(100% - 130px);box-shadow: 0 -5px 50px rgba(0, 0, 0, .2);"+position+": 24px;} .ie-iframe-fixed-customer-chat {background: transparent; border: none; height: 100%;} .ie-iframe-absolute-customer-chat {background: transparent; border: none; top: 0px; float:none; margin: 0px; padding: 0px; position: relative;"+position+": 24px;} .iframe-shadow {border-radius: 5px 5px 0 0;box-shadow: 0 -5px 50px rgba(0, 0, 0, .2);}";var head=document.head||document.getElementsByTagName("head")[0];var style=document.createElement("style");css=css+".button-iframe-wrap {bottom: 0px; position: fixed; height: 10%; display: block; z-index: 2147483638;} .ie-chat-button-iframe-fixed-customer-chat {background: transparent; border: none; bottom: 24px; position: fixed;"+position+": 24px; outline: none} .ie-chat-button-iframe-absolute-customer-chat {background: transparent; border: none; top: 0px; float:none; margin: 0px; padding: 0px; position: relative;"+position+": 24px;}";style.type="text/css";if(style.styleSheet){style.styleSheet.cssText=css}else{style.appendChild(document.createTextNode(css))}head.appendChild(style)}function addChatIframe(url,host){var d;var d1;var d2;d=document.createElement("div");d1=document.createElement("div");d2=document.createElement("div");d.className="ie-div-position-customer-chat";_frame=document.createElement("iframe");_frame.src=url;_frame.allowtransparency="true";_frame.frameborder="0px";_frame.id="icChat";_frame.name="icChat";_frame.title="Chat Window";_frame.scrolling="no";_frame.style.borderStyle="none";_frame.className="ie-iframe-fixed-customer-chat";d1.id="chat-div-wrap";d1.className="chat-iframe-wrap";d1.appendChild(_frame);_chatButtonFrame=document.createElement("iframe");_chatButtonFrame.src=host+"/inContact/ChatClient/chatButton.html";_chatButtonFrame.allowtransparency="true";_chatButtonFrame.frameborder="0px";_chatButtonFrame.id="icChatButton";_chatButtonFrame.name="icChatButton";_chatButtonFrame.scrolling="no";_chatButtonFrame.height=chatButtonH;_chatButtonFrame.width=chatButtonW;_chatButtonFrame.style.borderStyle="none";_chatButtonFrame.className="ie-chat-button-iframe-fixed-customer-chat";d2.className="button-iframe-wrap";d2.appendChild(_chatButtonFrame);d.appendChild(d1);d.appendChild(d2);document.body.appendChild(d)}function isMobileBrowser(){var isMobile=false;if(/Android/i.test(navigator.userAgent||navigator.vendor||window.opera)){isMobile=true}else if(/iPhone/i.test(navigator.userAgent||navigator.vendor||window.opera)){isMobile=true}else if(/BlackBerry/i.test(navigator.userAgent||navigator.vendor||window.opera)){isMobile=true}else if(/webOS/i.test(navigator.userAgent||navigator.vendor||window.opera)){isMobile=true}else if(/IEMobile/i.test(navigator.userAgent||navigator.vendor||window.opera)){isMobile=true}else if(/Opera Mini/i.test(navigator.userAgent||navigator.vendor||window.opera)){isMobile=true}else{isMobile=false}return isMobile}function onMessageReceived(event){var mt;var md;var popInChat;var ispopOutChat=sessionStorage.getItem("isPopOut")&&sessionStorage.getItem("isPopOut")!=="true"?false:true;var position;try{if(event.origin===_host){mt=event.data.messageType;md=event.data.data;switch(mt){case"resize":if(md.minimize===true){resizeChat(_frame,minH,minW);_frame.classList.remove("iframe-shadow");document.getElementById("chat-div-wrap").style.width="0"}else{if(customChatButton===true){if(customHeight&&customWidth!==null){resizeChat(_frame,customHeight,customWidth)}else{resizeChat(_frame,chatH,chatW)}_frame.classList.add("iframe-shadow");document.getElementById("chat-div-wrap").style.height=customHeight+"px";document.getElementById("chat-div-wrap").style.width=customWidth+"px"}else{resizeChat(_frame,chatH,chatW);_frame.classList.add("iframe-shadow");document.getElementById("chat-div-wrap").style.width=chatW+"px"}}if(customChatButton===false){_chatButtonFrame.contentWindow.postMessage({messageType:"resize",data:md},"*")}break;case"isPopOut":resizeChat(_frame,initialH,initialW);CHILD_WINDOW_HANDLE=window.open(_host+"/inContact/ChatClient/index.html","popOutWindow","width=380,height=600,left=200,top=100");sessionStorage.setItem("isChatProfileCalled","true");sessionStorage.setItem("isPopOut","true");popOutChat={messageType:"isPopOut",data:md};if(customChatButton===false){_chatButtonFrame.contentWindow.postMessage({messageType:"isPopOut",data:{isPopOut:true}},"*")}document.getElementById("chat-div-wrap").style.width="0";break;case"isPopIn":sessionStorage.setItem("isPopOut","false");popInChat={messageType:"isPopIn",data:md};_frame.contentWindow.postMessage(popInChat,"*");if(customChatButton===false){_chatButtonFrame.contentWindow.postMessage({messageType:"isPopIn",data:{isPopIn:true}},"*")}break;case"getStoreData":if(CHILD_WINDOW_HANDLE){setTimeout(function(){CHILD_WINDOW_HANDLE.postMessage(popOutChat,"*")},500)}break;case"chatButtonClick":if(isMobileBrowser()){_chatButtonFrame.contentWindow.postMessage({messageType:"resize",data:{minimize:true}},"*");win=window.open(_url,"_blank");win.focus()}else{_frame.contentWindow.postMessage({messageType:"chatButtonClick",data:md},"*")}break;case"messageCount":_chatButtonFrame.contentWindow.postMessage({messageType:"messageCount",data:md},"*");if(showBadge&&{}.toString.call(showBadge)==="[object Function]"){showBadge(md.msgCount)}break;case"chatProfile":_chatButtonFrame.contentWindow.postMessage({messageType:"chatProfile",data:md},"*");position=md.chatProfile.chatButtonPosition.toLowerCase()==="bottomleft"?"left":"right";addCss(position);if(sessionParameter!=="undefined"&&sessionParameter.length>0){_frame.contentWindow.postMessage({messageType:"storeParameter",data:sessionParameter},"*")}break;case"isChildWindowClosed":_frame.contentWindow.postMessage({messageType:"isChildWindowClosed",data:md},"*");break}}}catch(err){}}function setIpad(){if(/iPad/i.test(navigator.userAgent||navigator.vendor||window.opera)){isIpad=true}}function getHeight(height){if(height=window.innerHeight){height=window.innerHeight;document.getElementById("chat-div-wrap").style.maxHeight=height+"px"}return height}function getWidth(width){if(width=window.innerWidth-windowScrollWidth){width=window.innerWidth-windowScrollWidth}return width}function setXYPosition(left,top,width,height){var xPosition;var yPosition;xMax=window.innerWidth-width-browserScrollWidth;yMax=window.innerHeight-height;if(left>=0&&left<=xMax){xPosition=left}else if(left<0){xPosition=0}else if(xMax<=0){xPosition=0}else if(left>xMax){xPosition=xMax}if(top>=0&&top<=yMax){yPosition=top}else if(top<=0){yPosition=0}else if(top>yMax){yPosition=yMax}document.getElementById("chat-div-wrap").style.left=xPosition+"px";document.getElementById("chat-div-wrap").style.top=yPosition+"px"}function showEmbed(){var wDiff;var hDiff;var ispopOutChat=sessionStorage.getItem("isPopOut")&&sessionStorage.getItem("isPopOut")!=="true"?false:true;if(customChatButton===true&&_frame&&!ispopOutChat){if(isMobileBrowser()){_chatButtonFrame.contentWindow.postMessage({messageType:"resize",data:{minimize:true}},"*");win=window.open(_url,"_blank");win.focus()}else{if((customHeight&&customWidth)!==null){resizeChat(_frame,customHeight,customWidth)}else if((customHeight||customWidth)===null){wDiff=window.innerWidth-chatW;hDiff=window.innerHeight-chatH;leftPos=wDiff/2;topPos=hDiff/2;setXYPosition(leftPos,topPos,chatW,chatH);document.getElementById("chat-div-wrap").style.bottom=topPos+"px";resizeChat(_frame,chatH,chatW);document.getElementById("chat-div-wrap").style.width=chatW+"px";document.getElementById("chat-div-wrap").style.height=chatH+"px"}_frame.contentWindow.postMessage({messageType:"chatButtonClick",data:{minimize:false}},"*");document.getElementById("chat-div-wrap").style.width=_frame.width+"px";document.getElementById("chat-div-wrap").style.height=_frame.height+"px";if(showBadge&&{}.toString.call(showBadge)==="[object Function]"){showBadge(0)}}}else{if((customHeight||customWidth)!==null){wDiff=window.innerWidth-customWidth;hDiff=window.innerHeight-customHeight;if(hDiff/2>topPos){topPos=topPos}else if(hDiff/2===topPos){topPos=hDiff}else if(hDiff/2leftPos){leftPos=leftPos}else if(wDiff/2===leftPos){leftPos=wDiff}else if(wDiff/20){if(customChatButton===true&&!isMobileBrowser()){windowDimensions(windowConfig);showEmbed()}}}function addEventListener(){var eventMethod=window.addEventListener?"addEventListener":"attachEvent";var eventer=window[eventMethod];var messageEvent=eventMethod==="attachEvent"?"onmessage":"message";eventer(messageEvent,onMessageReceived,false);eventer("resize",onResize,false)}return{init:function(args,badgeRef){var q="";var opt=[];var i=0;if(args.serverHost&&args.bus_no&&args.poc){_host=args.serverHost;customChatButton=args.customChatButton?true:false;opt=args.params?args.params:[];for(i=0;i"0px"){this.hide()}else{if(CHILD_WINDOW_HANDLE!==null&&CHILD_WINDOW_HANDLE.closed===true){CHILD_WINDOW_HANDLE=null;_frame.contentWindow.postMessage({messageType:"isChildWindowClosed",data:{}},"*");sessionStorage.setItem("isPopOut","false");setTimeout(this.show,1e3)}else{this.show()}}}}}();